SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO


CREATE PROCEDURE dbo.[DnnProduct_GetUsers]
	@PortalID int
AS
	SELECT
			U.*, 
			UP.PortalId, 
			UP.Authorised, 
			UP.IsDeleted,
			UP.RefreshRoles 
	FROM dbo.DnnProduct_Users U
		LEFT JOIN dbo.DnnProduct_UserPortals UP on U.UserId = UP.UserId
	WHERE ( UP.PortalId = @PortalID or @PortalID is null )
	ORDER BY U.FirstName + ' ' + U.LastName   

GO
